package com.zcy.tag2;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class IterationTag extends SimpleTagSupport {
	private String var;
	private String[] iterms;

	public void setVar(String var) {
		this.var = var;
	}

	public void setIterms(String[] iterms) {
		this.iterms = iterms;
	}
	
	@Override
	public void doTag() throws JspException, IOException {

		if (iterms!=null&&iterms.length>0) {
			for (int i = 0; i < iterms.length; i++) {
				PageContext pageContext=(PageContext) getJspContext();
				pageContext.setAttribute(var, iterms[i]);
				getJspBody().invoke(null);
			}
		}
	}

}
